import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/acl/index/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/acl/index/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/acl/index/logout',
    method: 'post'
  })
}

//获取管理用户列表
export function getUser(page, limit, searchObj) {
  return request({ url: `/acl/user/${page}/${limit}`, method: 'get', params: searchObj })
}

//添加用户
export function addUser(user) {
  return request({ url: `/acl/user/save`, method: 'post', data: user })
}

//更新用户
export function updateUser(user) {
  return request({ url: `/acl/user/update`, method: 'put', data: user })
}

//删除用户
export function delUser(id) {
  return request({ url: `/acl/user/remove/${id}`, method: 'delete' })
}

//获取某个user信息
export function getUserById(id) {
  return request({ url: `/acl/user/get/${id}`, method: 'get' })
}

//获取某个user的角色信息
export function getUserRoleInfo(userId) {
  return request({ url: `/acl/user/toAssign/${userId}`, method: 'get' })
}

//根据user分配角色
export function userDoAssign(userId, roleId) {
  return request({ url: `/acl/user/doAssign`, method: 'post', params: { userId, roleId } })
}